<template>
  <div class="billing-section">
    <div class="billing-card">
      <div class="billing-label">累计耗电</div>
      <div class="billing-value">{{ totalPower.toFixed(3) }} 度</div>
    </div>
    <div class="billing-card">
      <div class="billing-label">累计费用</div>
      <div class="billing-value primary">¥{{ totalCost.toFixed(2) }}</div>
    </div>
    <div v-if="realtimeCost" class="billing-card realtime">
      <div class="billing-label">实时扣费</div>
      <div class="billing-value highlight">{{ realtimeCost }}</div>
    </div>
  </div>
</template>

<script setup lang="ts">
const props = defineProps<{
  totalPower: number;
  totalCost: number;
  realtimeCost?: string;
}>();
</script>

<style scoped>
.billing-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.billing-card {
  background: #f9fafb;
  padding: 20px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  text-align: center;
  transition: all 0.2s;
}

.billing-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.billing-card.realtime {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border-color: #fbbf24;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

.billing-label {
  font-size: 13px;
  color: #6b7280;
  margin-bottom: 8px;
  font-weight: 500;
}

.billing-value {
  font-size: 24px;
  font-weight: 700;
  color: #111827;
}

.billing-value.primary {
  color: #10b981;
}

.billing-value.highlight {
  color: #d97706;
}

@media (max-width: 768px) {
  .billing-section {
    grid-template-columns: 1fr;
  }
}
</style>

